//Copyright 2009 Dominik Punz
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

#ifndef JNIAGENTWRAPPER_123123123
#define JNIAGENTWRAPPER_123123123

#include "silktestlib_i.h"
#include "jniEnvironment.h"
#include "javaReflection.h"
#include <jni.h>
#include <set>
#include <string>

class CDesktop;

class CJtfDesktop
{
public:
  CJtfDesktop(CDesktop* desktop);
	CJtfDesktop(CDesktop* desktop, BSTR hostname, LONG port);
  ~CJtfDesktop();

  void Attach(BSTR moduleNamePattern, BSTR commandLinePattern, BSTR techDomains);
  void DetachAll();  

  IDispatch* ExecuteBasestate(BSTR executable, BSTR commandLine, BSTR mainWindowLocator, BSTR techDomains);
  IDispatch* ExecuteBrowserBasestate(BSTR executable, BSTR url, BSTR mainWindowLocator, BSTR techDomains);
  IDispatch* Find(BSTR locator);
  IDispatch* FindAll(BSTR locator);
  IDispatch* GetChildren();
  void GetOption(BSTR optionName, VARIANT* pValue);
  void GetTechDomainOption(BSTR optionName, BSTR techdomain, VARIANT* pValue);
  void SetOption(BSTR optionName, VARIANT optionValue);
  void SetTechDomainOption(BSTR optionName, BSTR techdomain, VARIANT optionValue);
  void ResetAllOptions();

private:
  void SetJtfDesktop(jobject jobjJtfDesktop);

private:
  CJavaReflection mReflection;
  jobject mjobjDesktop;
  CDesktop* mpDesktop;
  CJniEnvironment mEnvironment;
};

#endif
